GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#709)
by
unknown
05:43
created

user_edit.js ➔ clearRole   B

Complexity

Conditions 8

Size

Total Lines 19
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 8
c 0
b 0
f 0
dl 0
loc 19
rs 7.3333
eloc 12
1
$(document).on('turbolinks:load', function(){
2
    var controller = $("body").data('controller');
3
    var action = $("body").data('action');
4
    if ((controller == "admins" && action == "edit_user") || (controller == "users" && action == "edit")) {
5
        $(".setting-btn").click(function(data){
6
            var url = $("body").data("relative-root")
7
            if (!url.endsWith("/")) {
8
                url += "/"
9
            }
10
            url += "admins?setting=" + data.target.id
11
12
            window.location.href = url
13
        })
14
15
        $(".clear-role").click(clearRole)
16
17
        $("#role-select-dropdown").change(function(data){
18
            var dropdown = $("#role-select-dropdown");
19
            var select_role_id = dropdown.val();
20
21
            if(select_role_id){
22
                var selected_role = dropdown.find('[value=\"' + select_role_id + '\"]');
23
                selected_role.prop("disabled", true)
24
25
                var tag_container = $("#role-tag-container");
26
                tag_container.append("<span id=\"user-role-tag_" + select_role_id + "\" style=\"background-color:" + selected_role.data("colour") + ";\" class=\"tag\">" + 
27
                    selected_role.text() + "<a data-role-id=\"" + select_role_id + "\" class=\"tag-addon clear-role\"><i data-role-id=\"" + select_role_id + "\" class=\"fas fa-times\"></i></a></span>");
28
29
                var role_ids = $("#user_role_ids").val()
30
                role_ids += " " + select_role_id
31
                $("#user_role_ids").val(role_ids)
32
                
33
                $("#user-role-tag_" + select_role_id).click(clearRole);
34
                dropdown.val(null)
35
            }
36
        })
37
    }
38
})
39
40
function clearRole(data){
41
    var role_id = $(data.target).data("role-id");
42
    var role_tag = $("#user-role-tag_" + role_id);
43
    $(role_tag).remove()
44
  
45
    var role_ids = $("#user_role_ids").val()
46
    var parsed_ids = role_ids.split(' ')
47
  
48
    var index = parsed_ids.indexOf(role_id.toString());
49
  
50
    if (index > -1) {
51
        parsed_ids.splice(index, 1);
52
    }
53
  
54
    $("#user_role_ids").val(parsed_ids.join(' '))
55
  
56
    var selected_role = $("#role-select-dropdown").find('[value=\"' + role_id + '\"]');
57
    selected_role.prop("disabled", false)
58
}